<template>
	<view>
		<view class="swiper-box">
			<swiper :autoplay="true" :circular="true" :interval="3000" :duration="1000" @change="onChange"
				class="swiper-box" style="overflow: hidden;">
				<swiper-item v-for="(item,index) in swiperData" :key='index'>
					<view class="swiper-item">
						<image v-if="isSchool" :src="'/api'+item.firstImage" mode="widthFix"></image>
						<image v-else :src="'/api'+item.imageUrl" mode="widthFix"></image>
					</view>
				</swiper-item>
			</swiper>
			<view class="swiper-bottom">
				<view class="swiper-bottom-fraction">
					<text class="swiper-bottom-nowId">{{swiperId}}</text>
					<text class="swiper-bottom-number">/{{swiperNum}}</text>
				</view>
				<text v-if="isSchool" class="swiper-bottom-text">{{swiperData[swiperId - 1]?swiperData[swiperId - 1].schoolName:''}}</text>
				<text v-else class="swiper-bottom-text">{{swiperData[swiperId - 1]?swiperData[swiperId - 1].explains:''}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getAllBannerList
	} from '../../api/api.js'
	export default {
		name: "component-swiper",
		props: {
			data:{},
			swiperLength:0,
			isSchool:false
		},
		data() {
			return {
				swiperId: 1,
				swiperNum: this.swiperLength,
				swiperData: this.data
			};
		},
		mounted() {
		},
		methods: {
			onChange(e) {
				const index = e.detail.current
				this.swiperId = index + 1
			}
		}
	}
</script>

<style>
	.swiper-box {
		width: 704rpx;
		height: 423rpx;
		border-radius: 12rpx;
		margin: 10rpx auto;
		position: relative;
	}

	.swiper-item {
		height: 423rpx;
		border-radius: 12rpx;
	}

	.swiper-item>image {
		width: 704rpx;
		border-radius: 12rpx;
	}

	.swiper-box>.swiper-bottom {
		width: 100%;
		height: 70rpx;
		background: rgba(0, 0, 0, 0.45);
		border-radius: 12rpx;
		position: absolute;
		bottom: 0;
		display: flex;
		align-items: center;
	}

	.swiper-bottom>.swiper-bottom-fraction {
		color: white;
		font-size: 40rpx;
		position: absolute;
		left: 33rpx;
	}

	.swiper-bottom>.swiper-bottom-fraction>.swiper-bottom-number {
		font-size: 20rpx;
	}

	.swiper-bottom>.swiper-bottom-text {
		font-size: 28rpx;
		font-weight: bolder;
		color: white;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		margin-left: 90rpx;
	}
</style>
